//
//  UIImage+extension.swift
//  新浪微博
//
//  Created by dafei on 16/5/28.
//  Copyright © 2016年 itheima. All rights reserved.
//

import UIKit

extension UIImage {

    class func snapShontCurrentWindow() -> UIImage {
    
        let window = UIApplication.sharedApplication().keyWindow!
        //开启上下文
        UIGraphicsBeginImageContextWithOptions(window.bounds.size, false, UIScreen.mainScreen().scale)
        //需要将要window 中显示的内容滑到图片上下文
        window.drawViewHierarchyInRect(window.bounds, afterScreenUpdates: false)
        //从图形上下文中获取图片
        let image = UIGraphicsGetImageFromCurrentImageContext()
        
        //关闭图形上下文
        UIGraphicsEndImageContext()
        
        return image
  
    }
  
}



